package com.tarena.spring.test.config;

import com.tarena.spring.test.anno.ConditionalOnWindows;
import com.tarena.spring.test.bean.Bean01;
import com.tarena.spring.test.bean.Bean04;
import com.tarena.spring.test.condition.OSCondtion;
import com.tarena.spring.test.selector.MyImportSelector;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.*;

/**
 * 代表和demo01.xml同等作用的配置类
 */

@Configuration
@ComponentScan(basePackages = {
        "com.tarena.spring.test.bean",
        "com.tarena.spring.test.conditional"})
//@Import(value = {Demo02Configuration.class})
@Import(value={MyImportSelector.class})
@PropertySource("jdbc.properties")
//@ConditionalOnWindows
public class Demo01Configuration {
    @Bean("bean01")
    public Bean01 bean01(){
        return new Bean01();
    }
    @ConditionalOnProperty(
            prefix = "user",
            value="tedu.password",
            havingValue = "123456",
            matchIfMissing = true)
    @Bean("bean04")
    public Bean04 bean04(){
        return new Bean04();
    }
}
